#!/usr/bin/env python 
# -*- coding:utf-8 -*-

import time
import ruamel.yaml as yaml
from active.tableStatus import DataToInflux, TableStatus
from logger import logger


def main():
    logger.info("获取数据库信息")
    ys = yaml.load(open('./conf/dbinfo.yaml', 'r').read(), Loader=yaml.Loader)
    for db in ys['DBDIC_INFO']['mysql']:
        logger.info("获取各个库中表数据量")
        if "-03" in db["host"]:
            rs = TableStatus().getTableRowsList(db)
            logger.info("表数据量记录到influx")
            series = DataToInflux().setInfluxData(rs)
            DataToInflux().sendDataToInflux(series)
            time.sleep(2)
        # exit(1)


if __name__ == '__main__':
    main()
